home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Disk C Library Procedures Disk
-
-
-
- _________________________________________________________________
-
- NNAAMMEE
- Disk_ReadLabel, Disk_WriteLabel, Disk_EraseLabel, |
- Disk_NewLabel,Disk_ReadDecLabel, Disk_WriteDecLabel, |
- Disk_ReadSunLabel, Disk_WriteSunLabel, |
- Disk_ReadDomainHeader, Disk_WriteDomainHeader, |
- Disk_ReadSummaryInfo, Disk_WriteSummaryInfo, |
- Disk_SectorRead, Disk_SectorWrite, Disk_BlockRead, |
- Disk_BlockWrite, Disk_BadBlockRead, Disk_FragRead, |
- Disk_FragWrite, Disk_PrintDomainHeader, |
- Disk_PrintSummaryInfo, Disk_PrintFileDescBitmap, |
- Disk_PrintDataBlockBitmap, Disk_PrintDirEntry, |
- Disk_PrintLabel - Package for accessing OFS file systems via |
- raw disks
-
- SSYYNNOOPPSSIISS
- #include <disk.h> |
-
- Disk_Label * |
- DDiisskk__RReeaaddLLaabbeell(_f_i_l_e_I_D) |
- int |
- DDiisskk__WWrriitteeLLaabbeell(_f_i_l_e_I_D, _l_a_b_e_l_P_t_r) |
- Disk_Label * |
- DDiisskk__NNeewwLLaabbeell(_l_a_b_e_l_T_y_p_e) |
- int |
- DDiisskk__EErraasseeLLaabbeell(_f_i_l_e_I_D, _l_a_b_e_l_T_y_p_e) |
- Dec_DiskLabel * |
- DDiisskk__RReeaaddDDeeccLLaabbeell(_f_i_l_e_I_D) |
- int |
- DDiisskk__WWrriitteeDDeeccLLaabbeell(_f_i_l_e_I_D, _d_e_c_L_a_b_e_l_P_t_r) |
- Sun_DiskLabel *
- DDiisskk__RReeaaddSSuunnLLaabbeell(_f_i_l_e_I_D)
- int |
- DDiisskk__WWrriitteeSSuunnLLaabbeell(_f_i_l_e_I_D, _s_u_n_L_a_b_e_l_P_t_r) |
- Ofs_DomainHeader * |
- DDiisskk__RReeaaddDDoommaaiinnHHeeaaddeerr(_f_i_l_e_I_D, _l_a_b_e_l_P_t_r) |
- int |
- DDiisskk__WWrriitteeDDoommaaiinnHHeeaaddeerr(_f_i_l_e_I_D, _l_a_b_e_l_P_t_r, _h_e_a_d_e_r_P_t_r) |
- Ofs_SummaryInfo * |
- DDiisskk__RReeaaddSSuummmmaarryyIInnffoo(_f_i_l_e_I_D, _l_a_b_e_l_P_t_r) |
- int |
- DDiisskk__WWrriitteeSSuummmmaarryyIInnffoo(_f_i_l_e_I_D, _l_a_b_e_l_P_t_r, _s_u_m_m_a_r_y_P_t_r) |
- int
- DDiisskk__SSeeccttoorrRReeaadd(_f_i_l_e_I_D, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
- int
- DDiisskk__SSeeccttoorrWWrriittee(_f_i_l_e_I_D, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
- int
- DDiisskk__BBlloocckkRReeaadd(_f_i_l_e_I_D, _h_e_a_d_e_r_P_t_r, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
- int
- DDiisskk__BBlloocckkWWrriittee(_f_i_l_e_I_D, _h_e_a_d_e_r_P_t_r, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
- int
-
-
-
- Sprite v.1.0 Printed: October 31, 1990 1
-
-
-
-
-
-
- Disk C Library Procedures Disk
-
-
-
- DDiisskk__BBaaddBBlloocckkRReeaadd(_f_i_l_e_I_D, _h_e_a_d_e_r_P_t_r, _i_n_d_e_x, _b_u_f_f_e_r)
- int
- DDiisskk__FFrraaggRReeaadd(_f_i_l_e_I_D, _h_e_a_d_e_r_P_t_r, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
- int
- DDiisskk__FFrraaggWWrriittee(_f_i_l_e_I_D, _h_e_a_d_e_r_P_t_r, _i_n_d_e_x, _c_o_u_n_t, _b_u_f_f_e_r)
- void
- DDiisskk__PPrriinnttDDoommaaiinnHHeeaaddeerr(_h_e_a_d_e_r_P_t_r)
- void
- DDiisskk__PPrriinnttSSuummmmaarryyIInnffoo(_s_u_m_m_a_r_y_P_t_r)
- DDiisskk__PPrriinnttLLaabbeell(_l_a_b_e_l_P_t_r) |
- void
- DDiisskk__PPrriinnttFFiilleeDDeessccBBiittmmaapp(_h_e_a_d_e_r_P_t_r, _b_i_t_m_a_p)
- void
- DDiisskk__PPrriinnttDDaattaaBBlloocckkBBiittmmaapp(_h_e_a_d_e_r_P_t_r, _b_i_t_m_a_p)
- void
- DDiisskk__PPrriinnttDDiirrEEnnttrryy(_d_i_r_E_n_t_r_y_P_t_r)
-
-
- AARRGGUUMMEENNTTSS
- int _f_i_l_e_I_D (in) File descriptor
- from ooppeenn of raw
- disk.
-
- int _p_a_r_t_i_t_i_o_n (in) Index of parti-
- tion to access,
- 0-7. |
-
- Disk_Label *_l_a_b_e_l_P_t_r (in) ||
- Basic disk infor- |
- mation from |
- DDiisskk__RReeaaddLLaabbeell. |
-
- Disk_NativeLabelType _l_a_b_e_l_T_y_p_e(in) ||
- Type of machine- |
- specific (native) |
- disk label on the |
- disk. |
-
- Dec_DiskLabel *_d_e_c_L_a_b_e_l_P_t_r ||
- Native disk label |
- for ds3100s. |
-
- Sun_DiskLabel *_s_u_n_L_a_b_e_l_P_t_r ||
- Native disk label |
- for Suns.
-
- int _i_n_d_e_x (in) Index of first
- (sector/block/fragment)
- to transfer.
-
- int _c_o_u_n_t (in) Number of
- (sectors/blocks/fragments)
-
-
-
- Sprite v.1.0 Printed: October 31, 1990 2
-
-
-
-
-
-
- Disk C Library Procedures Disk
-
-
-
- to transfer.
-
- char *_b_u_f_f_e_r (in) Buffer for data
- transferred.
-
- Ofs_DomainHeader *_h_e_a_d_e_r_P_t_r (in) Disk header
- information from
- DDiisskk__RReeaaddDDiisskkHHeeaaddeerr.
-
- Ofs_SummaryInfo *_s_u_m_m_a_r_y_P_t_r (in) Disk summary
- information sec-
- tor.
-
- char *_b_i_t_m_a_p (in) Array of bitmap
- bytes.
-
- Fslcl_DirEntry *_d_i_r_E_n_t_r_y_P_t_r (in) Directory entry
- structure.
-
- _________________________________________________________________
-
-
- IINNTTRROODDUUCCTTIIOONN
- The DDiisskk package is used to read and write raw disks that
- are formatted to contain Sprite file systems. To use these
- routines correctly it is important to understand disk _p_a_r_t_i_-
- _t_i_o_n_s, file system _h_e_a_d_e_r _i_n_f_o_r_m_a_t_i_o_n, file system _b_l_o_c_k_s,
- and file system block _f_r_a_g_m_e_n_t_s.
-
- Each physical disk is divided into as many as 8 partitions.
- The letters 'a' through 'h' are used to distinguish these
- different partitions in the names of the special device
- files that are used to access them. Thus ``/dev/rsd0a''
- references the first (zero'th) partition on disk rrssdd00. The |
- partitioning information is stored on the disk in the ``disk |
- label''. This label is in a machine-dependent format, and |
- is referred to as the ``native disk label''. Native disk |
- labels are kept in a machine-dependent location on the disk. |
- This is usually in sector 0 or some other sector near the |
- start of the first partition. The ffssmmaakkee program also |
- copies the label to a partition when it formats it into a |
- file system. The routines DDiisskk__RReeaaddSSuunnLLaabbeell and |
- DDiisskk__RReeaaddDDeeccLLaabbeell can be used to read the native disk |
- labels. |
-
- It is not always convenient to deal with native disk labels. |
- For this reason a generic label type and associated routines |
- have been provided. The type DDiisskk__LLaabbeell is a standard for- |
- mat for disk labels. The routine DDiisskk__RReeaaddLLaabbeell is used to |
- read a native disk label off the disk and convert it into a |
- DDiisskk__LLaabbeell. The routine DDiisskk__WWrriitteeLLaabbeell will convert a |
- DDiisskk__LLaabbeell into a native disk label and write it on the |
- disk. Two more procedures are provided for manipulating |
- disk labels. DDiisskk__EErraasseeLLaabbeell will erase a native disk label |
-
-
-
- Sprite v.1.0 Printed: October 31, 1990 3
-
-
-
-
-
-
- Disk C Library Procedures Disk
-
-
-
- from the disk, and DDiisskk__NNeewwLLaabbeell is used to create a new |
- label if the disk does not have one already. The contents |
- of a DDiisskk__LLaabbeell are defined in <disk.h>.
-
- The detailed structure of the file system is defined by a
- Ofs_DomainHeader structure that located on the disk accord-
- ing to the DDiisskk__LLaabbeell. This can be obtained with the
- DDiisskk__RReeaaddDDoommaaiinnHHeeaaddeerr procedure. The Ofs_DomainHeader
- structure is defined in <kernel/fsdm.h>, and is passed to
- the block and fragment I/O routines so they can correctly
- locate blocks and fragments.
-
- A secondary data structure called the summary information is |
- kept on disk following the domain header. The summary |
- information consists of a single sector and contains such |
- information as the number of free blocks and file descrip- |
- tors. The Ofs_SummaryInfo structure is defined in |
- <kernel/fsdm.h>. The location of the summary sector is |
- stored in the DDiisskk__LLaabbeell. The summary sector can be read |
- and written using the DDiisskk__RReeaaddSSuummmmaarryyIInnffoo and |
- DDiisskk__WWrriitteeSSuummmmaarryyIInnffoo procedures.
-
- SSEECCTTOORR II//OO
- DDiisskk__SSeeccttoorrRReeaadd and DDiisskk__SSeeccttoorrWWrriittee read and write sectors
- from the disk without regard to the underlying block struc-
- ture. Their _i_n_d_e_x argument specifies the first sector
- (starting from zero) to transfer, relative to the start of
- the partition. The sector offsets given in the DDiisskk__LLaabbeell
- structure are useful with this routine.
-
- BBLLOOCCKK II//OO
- The file system is arranged in block-sized chunks on the
- disk. FFSS__BBLLOOCCKK__SSIIZZEE defines how many bytes this is
- (currently 4 Kbytes). Due to disk geometry considerations
- consecutive blocks may or may not be contiguous on disk.
- DDiisskk__BBlloocckkRReeaadd and DDiisskk__BBlloocckkWWrriittee use geometry and block
- layout information in the Ofs_DomainHeader to correctly
- locate disk blocks. The _i_n_d_e_x argument to these routines is
- a block index, counting from the beginning of the partition
- (see the warning below!).
-
- DDiisskk__BBaaddBBlloocckkRReeaadd is used to re-read a bad file system block
- and determine which sectors are bad. It returns a bitmask
- with bits set to indicate which of the sectors were success-
- fully read. Bit _i in the mask corresponds to sector _i in
- the block. DDIISSKK__SSEECCTTOORRSS__PPEERR__BBLLOOCCKK defines how many sector
- there are in each file system block.
-
- FFRRAAGGMMEENNTT II//OO
- Each file system block is sub-divided into fragments to
- optimize allocation of small files. Currently the fragment
- size is 1 Kbyte, so there are 4 fragments to each block.
-
-
-
- Sprite v.1.0 Printed: October 31, 1990 4
-
-
-
-
-
-
- Disk C Library Procedures Disk
-
-
-
- DDiisskk__FFrraaggRReeaadd and DDiisskk__FFrraaggWWrriittee are used to read and write
- fragments. The _i_n_d_e_x argument to these routines is a frag-
- ment index, counting from the beginning of the partition
- (see the warning below!). The _c_o_u_n_t argument to these rou-
- tines should not be greater than the number of fragments per
- file system block.
-
- BBLLOOCCKK AANNDD FFRRAAGGMMEENNTT IINNDDEEXXEESS
- WWAARRNNIINNGG:: there are several caveats about block numbers and
- fragment numbers as used by the Sprite file system. A par-
- tition is divided into areas for bitmaps, file descriptors,
- and data blocks. These divisions are specified in the
- Ofs_DomainHeader structure in terms of block offsets and
- number of blocks. However, _b_l_o_c_k _n_u_m_b_e_r_s _a_r_e _n_o_t _k_e_p_t _i_n
- _d_i_s_k _m_a_p_s, _o_n_l_y _f_r_a_g_m_e_n_t _n_u_m_b_e_r_s. When traversing the
- direct and indirect blocks that define where a file's blocks
- are, fragment indexes must be converted to block indexes
- before using either DDiisskk__BBlloocckkRReeaadd or DDiisskk__BBlloocckkWWrriittee.
- Also, _d_i_r_e_c_t _b_l_o_c_k _p_o_i_n_t_e_r_s _i_n _t_h_e _m_a_p_s _a_r_e _f_r_a_g_m_e_n_t _i_n_d_e_x_e_s
- _r_e_l_a_t_i_v_e _t_o _t_h_e _s_t_a_r_t _o_f _t_h_e _d_a_t_a _b_l_o_c_k _a_r_e_a _o_f _t_h_e _f_i_l_e
- _s_y_s_t_e_m. Thus to convert from a direct block pointer to a
- physical fragment index:
-
- fragIndex = blockPointer + (headerPtr->dataOffset * FS_FRAGMENTS_PER_BLOCK);
- blockIndex = fragIndex / FS_FRAGMENTS_PER_BLOCK;
-
- The last main caveat is that _i_n_d_i_r_e_c_t _b_l_o_c_k _p_o_i_n_t_e_r_s _a_r_e
- _p_h_y_s_i_c_a_l _f_r_a_g_m_e_n_t _i_n_d_e_x_e_s. They do not need to be offset in
- the same way as direct block pointers. This applies to any
- block pointer that points to an indirect block, never to a
- block pointer that points to a data block.
-
- PPRRIINNTTIINNGG UUTTIILLIITTIIEESS
- The last set of procedures in this package are used to print
- out contents of the file system. DDiisskk__PPrriinnttDDoommaaiinnHHeeaaddeerr
- prints out the domain header information.
- DDiisskk__PPrriinnttSSuummmmaarryyIInnffoo prints out the summary disk sector.
- This sector is used to keep the prefix under which the disk
- is exported, the current number of blocks allocated and
- free, and whether or not the disk was safely sync'ed at last
- reboot. DDiisskk__PPrriinnttFFiilleeDDeessccBBiittmmaapp and
- DDiisskk__PPrriinnttDDaattaaBBlloocckkBBiittmmaapp print out the file descriptor and
- data block bitmaps in hex. A zero bit represents a free
- descriptor or block. DDiisskk__PPrriinnttDDiirrEEnnttrryy prints out a direc-
- tory entry.
-
- SSEEEE AALLSSOO
- fscheck, fsmake, labeldisk, installboot
-
- KKEEYYWWOORRDDSS
- disk, block, sector, fragment
-
-
-
-
- Sprite v.1.0 Printed: October 31, 1990 5
-
-
-
-
-
-
- Disk C Library Procedures Disk
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Sprite v.1.0 Printed: October 31, 1990 6
-
-
-
-
-
-
-